#include "api.h"
#include <time.h>
#if defined(WIN32) || defined(_WIN32)
#include <Windows.h>
#else
#include <sys/time.h>
#include <unistd.h>
#endif

int64_t GetMS()
{
	int64_t ms = 0;
#if defined(WIN32) || defined(_WIN32)
	SYSTEMTIME sys;
	GetLocalTime(&sys);
	tm temptm = {sys.wSecond,
				 sys.wMinute,
				 sys.wHour,
				 sys.wDay,
				 sys.wMonth - 1,
				 sys.wYear - 1900,
				 sys.wDayOfWeek,
				 0,
				 0};
	ms = mktime(&temptm);
	ms = ms * 1000 + sys.wMilliseconds;
#else
	struct timeval tv;
	gettimeofday(&tv, NULL);
	ms = tv.tv_sec * 1000 + tv.tv_usec / 1000;
#endif
	return ms;
}